from dependency_injector import containers, providers

from fastapi_template.common.connections import get_async_redis_client
from fastapi_template.domains.permission import (PermissionFacade,
                                                 PermissionFacadeImpl)
from fastapi_template.domains.role import RoleFacade, RoleFacadeImpl
from fastapi_template.domains.user import UserFacade, UserFacadeImpl

__all__ = ["Container"]


class Container(containers.DeclarativeContainer):
    wiring_config = containers.WiringConfiguration(modules=[
        "fastapi_template.apis.public.user.router",
        "fastapi_template.apis.public.role.router",
        "fastapi_template.apis.public.permission.router",
    ])

    redis_client = providers.Resource(get_async_redis_client)

    # User domain
    user_facade: providers.Resource[UserFacade] = providers.Resource(
        UserFacadeImpl)

    # Role domain
    role_facade: providers.Resource[RoleFacade] = providers.Resource(
        RoleFacadeImpl)

    # Permission domain
    permission_facade: providers.Resource[
        PermissionFacade] = providers.Resource(PermissionFacadeImpl)
